<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="container-div">
    <input type="hidden" id="userId" name="userId" th:value="*{userId}">

    <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
        <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="module:userInvite:add">
            <i class="fa fa-plus"></i> 添加
        </a>
        <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()"
           shiro:hasPermission="module:userInvite:edit">
            <i class="fa fa-edit"></i> 修改
        </a>
        <a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()"
           shiro:hasPermission="module:userInvite:remove">
            <i class="fa fa-remove"></i> 删除
        </a>
    </div>

    <div class="col-sm-12 select-table table-striped">
        <table id="bootstrap-table" data-mobile-responsive="true"></table>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('module:userInvite:edit')}]];
    var removeFlag = [[${@permission.hasPermi('module:userInvite:remove')}]];
    var userType = [[${@dict.getType('user_type')}]];
    var delFlag = [[${@dict.getType('del_flag')}]];
    var prefix = ctx + "module/userInvite";

    $(function () {
        var options = {
            url: prefix + "/oneList",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            modalName: "用户邀请关系",
            queryParams: queryParams,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'phone',
                    title: '手机号'
                },
                {
                    field: 'nickName',
                    title: '昵称',
                    formatter: function (value, row, index) {
                        return '<a href="#" onclick="detail(\'' + row.userId + '\')">' + value + '</a>';
                    }
                },
                {
                    field: 'userType',
                    title: '用户类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(userType, value);
                    }
                },
                {
                    field: 'delFlag',
                    title: '状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(delFlag, value);
                    }
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    sortable: true
                }
                ]
        };
        $.table.init(options);
    });

    /*订单-详细*/
    function detail(orderId) {
        var url = prefix + '/detail/' + orderId;
        createMenuItem(url, "下级推荐");
    }

    function queryParams(params) {
        return {
            userId:       $("#userId").val(),
            pageSize:       params.limit,
            pageNum:        params.offset / params.limit + 1,
            searchValue:    params.search,
            orderByColumn:  params.sort,
            isAsc:          params.order
        };
    }
</script>
</body>
</html>